B = $(HOME)/Documents/programs/c/bin

SRCS   = $(wildcard *.c)
OBJS   = $(patsubst %.c, %, $(SRCS))
BINS   = $(patsubst %, $B/%, $(OBJS))

# compiler and flags
CC     = gcc
CFLAGS = -Wall -Werror

# rules
%: %.c
	@echo + CC $<
	@$(CC) $(CFLAGS) $< -o $@

$B/%: %.c
	$(CC) $(CFLAGS) $< -o $@

# targets
all: $(OBJS)

install: $(BINS)

clean:
	rm -f $(OBJS)

uninstall:
	rm -f $(BINS)

.PHONY: all clean install uninstall
